package com.st.service.impl;

import com.alibaba.fastjson.JSON;
import com.st.dao.BookDao;
import com.st.pojo.BookBean;
import com.st.pojo.Message;
import com.st.service.AMQProductionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class AMQProductionServiceImpl implements AMQProductionService {
    @Resource
    private BookDao bookDao;

    @Autowired
    @Qualifier("jmsTemplate")
    private JmsTemplate jmsTemplate;

    public void setJmsTemplate(JmsTemplate jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }


    //向特定的队列发送消息
    @Override
    public void sendMsg(BookBean bookBean) {
        jmsTemplate.convertAndSend(bookBean);
    }

    @Override
    public int addOrder(BookBean bookBean) {
       return bookDao.addOrder(bookBean);
    }
}
